package com.myproject.exception;

import com.myproject.enums.ErrorCode;

public class BusinessException extends RuntimeException {
	
	private final int code;
	private final String message;

	public BusinessException(ErrorCode errorCode) {
		super(errorCode.getMessage());
		this.code = errorCode.getCode();
		this.message = errorCode.getMessage();
	}

	public BusinessException(ErrorCode errorCode, String message) {
		super(message);
		this.code = errorCode.getCode();
		this.message = errorCode.getMessage();
	}

	public BusinessException(int code, String message) {
		super(message);
		this.code = code;
		this.message = message;
	}

	public BusinessException(int code, String message, Throwable cause) {
		super(message, cause);
		this.code = code;
		this.message = message;
	}

	// Getters
	public int getCode() {
		return code;
	}

	@Override
	public String getMessage() {
		return message;
	}
}